<?php

/************************************************************
 * 文章系统处理工具
 * time		2014-08-20
 * author	liuricheng
 * 
 ***********************************************************/


function get_sql_auto_goods(){
	$CommonModel	=	new CommonModel();
    $where 			= 	'';
    if (!empty($_POST['goods_name'])){
        $goods_name 			= 	trim($_POST['goods_name']);
        $where 					= 	" WHERE g.title LIKE '%$goods_name%'";
        $filter['goods_name'] 	= 	$goods_name;
    }
    $sql 						= 	"SELECT COUNT(*) FROM " . 'ybr_article' . " g" . $where;
    $filter['record_count'] 	=	$CommonModel->getOne($sql);
    $goodsdb 					= 	array();
    $sql 						= 	"SELECT g.*,a.starttime,a.endtime FROM " . 'ybr_article' . " g LEFT JOIN " . 'ybr_auto_manage' . " a ON g.article_id = a.item_id AND a.type='article'" . $where .
           							" ORDER BY g. add_time DESC" ;
    
    return $sql; 
}